package com.lp.mgt.controllers;



import java.util.List;
import java.util.stream.Collectors;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import com.lp.mgt.entities.TableInfo;
import com.lp.mgt.services.FileAndExcelService;
import com.lp.mgt.utils.ExcelUtil;

@RequestMapping("file_excel")
@Controller
public class FileAndExcelCtr {
	@Autowired
	private FileAndExcelService fileAndExcelService;
	
	
	@GetMapping("/downloadModel")//下载导入模板。直接查所有表字段名
	public void downloadExcelModel(HttpServletResponse response, String voName) {
		String  tableName="mgt_";
		if(!"".equals(voName)&&voName!=null) {
			tableName+=voName;
		}
		//获取表信息
		List<TableInfo> ti=fileAndExcelService.getTableInfoByName(tableName);
		ExcelUtil.exportExcel(response, ti, null,"用户导入模板");//导出模板
	}
		
}
